package cn.bdqn.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.RequestMapping;

import cn.bdqn.pojo.CustomerForm;
import cn.bdqn.pojo.CustomerRole;
import cn.bdqn.service.CustomerFormService;
import cn.bdqn.service.CustomerRoleService;
import cn.bdqn.service.SectionService;

@org.springframework.stereotype.Controller

public class Controller {
	
	@Resource
	private CustomerFormService userService;
	@Resource
	private CustomerRoleService Role;
	@Resource
	private SectionService Section;

	@RequestMapping("login")
	public String toLogin() {
		return "login";
	}

	CustomerForm user;

	@RequestMapping("index")
	public String dologin(String name, String password, HttpSession session) {
		user = userService.getLogin(name);
		if (user == null) {
			return "login";
		} else if (password.equals(user.getPassword())) {
			session.setAttribute("sessionUser", user);
			return "index";
		} else {
			return "login";
		}

	}

//	@RequestMapping()
//	public String Role(HttpServer session) {
//		
//		return "";
//	}

	@RequestMapping("user")
	public String selectuser() {

		return "";
	}

	@RequestMapping("userpasswordedit")
	public String userpassword(String password, HttpSession session) {
		if (user.getPassword().equals(password)) {
			if (userService.password(user.getName(), password) != 0) {
				return "login";
			}
			return "index";
		}
		return "index";
	}

	@RequestMapping("Yonghu-xiugai")
	public String Yonghuxiugai() {
		return "Yonghu-xiugai";
	}

	@RequestMapping("Yonghuguanli")
	public String Yonghuguanli(HttpSession session) {
		Map<Integer, String> map = null;
		if(Role.Role()==null) {
			System.out.println(1);
		}
		for (CustomerRole items : Role.Role()) {
			map.put(items.getId(), items.getRole());
		}
		session.setAttribute("role", map);
		session.setAttribute("section", Section.Sections());
		return "Yonghuguanli";
	}

	@RequestMapping("admin")
	public String admin() {
		return "admin";
	}

	@RequestMapping("gongGongShuXing-list")
	public String gongGongShuXinglist() {
		return "gongGongShuXing-list";
	}

	@RequestMapping("tiKuGuanLi")
	public String tiKuGuanLi() {
		return "tiKuGuanLi";
	}

	@RequestMapping("zhicheng")
	public String zhicheng() {
		return "zhicheng";
	}

	@RequestMapping("zhiwei")
	public String zhiwei() {
		return "zhiwei";
	}

	@RequestMapping("admin-role-add")
	public String adminroleadd() {
		return "admin-role-add";
	}

	@RequestMapping("picture-list")
	public String picturelist() {
		return "picture-list";
	}

	@RequestMapping("user-password-edit")
	public String userpasswordedit() {
		return "user-password-edit";
	}

	@RequestMapping("daiban")
	public String daiban() {
		return "daiban";
	}

	@RequestMapping("welcome")
	public String welcome() {
		return "welcome";
	}

	@RequestMapping("xinChouBiaoZhun")
	public String xinChouBiaoZhun() {
		return "xinChouBiaoZhun";
	}

	@RequestMapping("xinChouFaFang")
	public String xinChouFaFang() {
		return "xinChouFaFang";
	}

	@RequestMapping("renShiGuanLi")
	public String renShiGuanLi() {
		return "renShiGuanLi";
	}

	@RequestMapping("member-list")
	public String memberlist() {
		return "member-list";
	}

	@RequestMapping("member-del")
	public String memberdel() {
		return "member-del";
	}

	@RequestMapping("member-level")
	public String memberlevel() {
		return "member-level";
	}

	@RequestMapping("member-scoreoperation")
	public String memberscoreoperation() {
		return "member-scoreoperation";
	}

	@RequestMapping("admin-role")
	public String adminrole() {
		return "admin-role";
	}

	@RequestMapping("admin-permission")
	public String adminpermission() {
		return "admin-permission";
	}

	@RequestMapping("admin-list")
	public String adminlist() {
		return "admin-list";
	}

	@RequestMapping("zhigongmingxi")
	public String zhigongmingxi() {
		return "zhigongmingxi";
	}

	@RequestMapping("zhiyuanshuju")
	public String zhiyuanshuju() {
		return "zhiyuanshuju";
	}

	@RequestMapping("zhiyuanyidong")
	public String zhiyuanyidong() {
		return "zhiyuanyidong";
	}

	@RequestMapping("chubeirencai")
	public String chubeirencai() {
		return "chubeirencai";
	}

	@RequestMapping("tixijiegou")
	public String tixijiegou() {
		return "tixijiegou";
	}
}
